/*
 * EmployeeList.java
 *
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.javacore.day11.employeelist;

import java.util.LinkedList;
import java.util.Collections;
import java.util.Scanner;


/**
 *
 * @author somap
 */
public class EmployeeList {
  
  LinkedList objLinkedList ;
  
  /** Constructor initializing the LinkedList object.*/
  public EmployeeList() {
    objLinkedList = new LinkedList();
  }
  
  /** Adding values.*/
  void add() {
    Scanner input = new Scanner(System.in);
    String employeeName = "";
    System.out.println("Enter the name of the employee:");
    employeeName = input.nextLine();
    objLinkedList.add(employeeName);
  }
  
  /** Displaying values.*/
  
  void display() {
    System.out.println("\n**********************"
        + "****************");
    System.out.println("Retrieve objects from the LinkedList");
    System.out.println("*******************"
        + "*******************");
    System.out.println();
    
    for (int ctr = 0; ctr < objLinkedList.size(); ctr++) {
      System.out.print(objLinkedList.get(ctr) + "\n");
    }
    
    System.out.println();
  }
  
  
  /**
   * Searching for names having a certain value.
   * @param str receives a String argument
   */
  
  void search() {
    Scanner input = new Scanner(System.in);
    System.out.println("Enter the Employee name to search in the list");
    String searchName = "";
    searchName = input.nextLine();
    System.out.println("********************************"
        + "******************");
    System.out.println("Searching for specific objects"
        + " from the LinkedList");
    System.out.println("*****************************"
        + "*********************");
    System.out.println();
    
    for (int ctr = 0; ctr < objLinkedList.size(); ctr++) {
      Object name = objLinkedList.get(ctr);
      if (name.toString().startsWith(searchName)) {
        System.out.println(name);
      }
    }
  }
  
}